package com.shanks.home.module.ui;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.widget.ListView;

import com.shanks.home.R;
import com.shanks.home.model.UIData;
import com.shanks.home.ui.GridViewActivity;
import com.shanks.home.util.LogUtil;

public class UIActivity extends Activity {
	
	private static final String TAG = UIActivity.class.getSimpleName();
	
	private ListView listView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Intent intent = this.getIntent();
		Bundle bundle = intent.getExtras();
		String str = bundle.getString("shanks");
		LogUtil.i(TAG, str);
		
		this.setContentView(R.layout.activity_ui);
		initView();
		listViewFunc();
	}
	
	private void initView() {
		listView = (ListView)this.findViewById(R.id.ui_list_view_lv);
	}
	
	private void listViewFunc() {
		ArrayList<UIData> arrayList = new ArrayList<UIData>();
		for (int i = 0; i < 3; i ++) {
			UIData uiData = new UIData();
			if (i == 0) 
				uiData.id = UIData.GRIDVIEW;
			else if (i == 1)
				uiData.id = UIData.LISTVIEW;
			else if (i == 2)
				uiData.id = UIData.SEEKBAR;
			uiData.name = uiData.id;
			arrayList.add(uiData);
		}
		UIListAdapter uiListAdapter = new UIListAdapter(arrayList, this, this);
		listView.setAdapter(uiListAdapter);
		// 去掉点击的黄光
		listView.setSelector(new ColorDrawable(Color.TRANSPARENT));
	}
	
	public void clickGridView() {
		startActivity(new Intent(UIActivity.this, GridViewActivity.class));
	}
	
	public void clickSeekBar() {
		startActivity(new Intent(UIActivity.this, SeekBarActivity.class));
	}
}